package views.components
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	import maps.Map;
	import maps.Tile;
	
	/**
	 *
	 * 游戏框
	 *  
	 * @author Administrator
	 * 
	 */	
	public class GameBoard extends Sprite
	{
		private var w:int = 8;
		private var h:int = 15;
		private var map:Map = new Map(w, h);
		
		public function GameBoard()
		{
			super();
			
			init();
		}
		
		private function init():void
		{
			for(var i:int = 0; i < w; i++)
			{
				for(var j:int = 0; j < h; j++)
				{
					var type:int = Math.random() * 1;
					var s:Square = new Square(type);
					var tile:Tile = new Tile(new Point(i, j), type);
					s.tile = tile;
					tile.target = s;
					map.setTile(tile);
					s.x = 20 * tile.getPosition().x;
					s.y = 20 * tile.getPosition().y;
					this.addChild(s);
				}
			}
		}
	}
}